package net.odtel.mailadmin.services;

import java.util.List;


import net.odtel.mailadmin.dao.EmailAccountDAO;
import net.odtel.mailadmin.model.EmailAccount;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class EmailAccountServiceImpl implements EmailAccountService {

	private EmailAccountDAO emailAccountDAO;

	
	public void save(EmailAccount emailAccount) {
		emailAccountDAO.add(emailAccount);
	}

	@Autowired
	public void setEmailAccountDAO(EmailAccountDAO emailAccountDAO) {
		this.emailAccountDAO = emailAccountDAO;
	}

	@Transactional(propagation = Propagation.REQUIRED)
	public EmailAccount findByLogin(String login) {
		return this.emailAccountDAO.findByLogin(login);
	}

	
	public EmailAccount findById(Long Id) {
		return this.emailAccountDAO.findById(Id);
	}

	
	public List<EmailAccount> findAll() {
		return (List<EmailAccount>) this.emailAccountDAO.findAll();
	}

	public List<EmailAccount> findRange(int[] range) {
		return (List<EmailAccount>) this.emailAccountDAO.findRange(range);
	}
	
	public void remove(EmailAccount emailAccount) {
		emailAccountDAO.remove(emailAccount);
	}

	
	public void update(EmailAccount emailAccount) {
		emailAccountDAO.update(emailAccount);
	}
	
	public void remove(Long emailAccountId) {
		emailAccountDAO.remove(emailAccountId);

	}

	public boolean ifExist(String login) {
		return this.emailAccountDAO.ifExist(login);
	}

	public boolean inDomain(String domain) {
		return this.emailAccountDAO.inDomain(domain);
	}

	public int count() {
		return this.emailAccountDAO.count();
	}

}
